package com.tuo51.childcare.repository;

import com.tuo51.childcare.domain.dailytask.DailyTaskTemplate;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface DailyTaskTemplateRepository extends JpaRepository<DailyTaskTemplate,String>, JpaSpecificationExecutor<DailyTaskTemplate> {

    @Query(value = "SELECT t.* FROM user_daily_task_template t where t.monthMax > ?1 and t.monthMin <= ?1 " +
            "and dqMin <= ?2 and dqMax > ?2 and dimensionId = ?3 order by dailyIndex", nativeQuery = true)
    List<DailyTaskTemplate> findDimensionTaskTemplates(Integer month, Integer dq, String dimensionIds );
    List<DailyTaskTemplate> findAllByDimensionIdInOrderByCreatedDesc( List<String> dimensionIds );

}
